package com.itheima.demo;

public class demo02 {
    public static void main(String[] args) {
        //调用方法;
        useStringHandler(new StringHandler() {
            @Override
            public void printMessage(String msg) {
                System.out.println("我是匿名内部类!" + msg);
            }
        });
        useStringHandler(msg ->
            System.out.println("我是lambda表达式" + msg)
        );

        useStringHandler(msg ->
            System.out.println("我是lambda表达式简写,如果参数列表只有一个参数," +
                    "那么小括号和参数类型可以省略!")
        );
        useStringHandler((String mag) ->
            System.out.println("我是lambda表达式!")
        );

    }

    public static void useStringHandler(StringHandler stringHandler) {
        stringHandler.printMessage("itheima");
    }
}

interface StringHandler {
    void printMessage(String msg);
}
